<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .container {
      margin: 80px auto;
      width: 300px;
    }

    #tabs {
      width: 300px;
      height: 40px;
      border-bottom: 2px solid #000;
    }

    #tabs li {
      cursor: pointer;
      list-style: none;
      float: left;
      width: 100px;
      background: #ccc;
      text-align: center;
      height: 40px;
      line-height: 40px;
    }

    #tabs li.active {
      background: #000;
      color: #fff;
    }

    #content div {
      width: 300px;
      height: 300px;
      background: #ccc;
      display: none;
    }

    #content div.active {
      display: block;
    }
  </style>
</head>

<body>
  <div class="container">
    <ul id="tabs">
      <li class="active">菜单 1</li>
      <li>菜单 2</li>
      <li>菜单 3</li>
    </ul>
    <div id="content">
      <div class="active">内容00000001</div>
      <div>内容00000002</div>
      <div>内容00000003</div>
    </div>
  </div>
  <script>
    var aLi = document.getElementsByTagName('li')
    var aDiv = document.querySelectorAll('#content div');
    for (var i = 0; i < aLi.length; i++) {
      aLi[i].index = i;
      aLi[i].onclick = function () {
        // 更改处于激活状态的tab
        // 清空激活状态
        for (var i = 0; i < aLi.length; i++) {
          aLi[i].className = '';
          aDiv[i].className = ''
        }
        this.className = 'active';
        // 更改处于激活状态的content
        aDiv[this.index].className = 'active';
      }
    }
  </script>
</body>

</html>